package com.paziy.jan.calc;

import com.paziy.jan.calc.expressions.Expression;
import com.paziy.jan.calc.expressions.ReversePolishNotation;
import com.paziy.jan.calc.literals.UnknownLiteral;
import com.paziy.jan.calc.literals.numbers.Num;
import java.math.MathContext;



public class Main {


    public static void main(String[] args)  {

        String expression = "sin("+ Math.PI+") * 10000000000000000000000000000000";
        System.out.print(expression + " = ");
        try {
            Expression ex = new Expression(expression);
            ReversePolishNotation rpn = ex.makeRPN();
            Num num = rpn.evaluate();
            System.out.println(num.bigDecimalValue().round(new MathContext(23)));
        }
        catch (UnknownLiteral e) {
            System.out.format("error in string neaer \"%s\", start position is %s, end position is %s",
                    e.getMessage(),e.getStartError(), e.getEndError());
        }
        catch (Exception e) {}
    }

}
